function FilterNatureAuthorsEditors(n2)

% ValueFolder='/sps/isc/rneveu/EtudeIRM/Nature/Results/';
% ValueFolderTemp='/sps/isc/rneveu/EtudeIRM/Nature/ResultsJournal/';
% ValueFolderTemp2='/sps/isc/rneveu/EtudeIRM/Nature/ResultsEditor/';
% load('/sps/isc/rneveu/EtudeIRM/Nature/EtudeNature.mat');
ValueFolder='C:\Users\Remy Neveu\Desktop\Etude IRM\Analyse\cc in2p3\Nature\Results\';
ValueFolderTemp='C:\Users\Remy Neveu\Desktop\Etude IRM\Analyse\cc in2p3\Nature\ResultsJournal\';
ValueFolderTemp2='C:\Users\Remy Neveu\Desktop\Etude IRM\Analyse\cc in2p3\Nature\ResultsEditor\';
load('C:\Users\Remy Neveu\Desktop\Etude IRM\Analyse\cc in2p3\Nature\EtudeNature.mat');
VecEditors1Temp(1,:)=[];
FirstNameEditor=VecEditors1Temp{n2,1};
LastNameEditor=VecEditors1Temp{n2,2};
VecA=192:1:198;
VecA=[VecA 65];
Veca=224:1:230;
Veca=[Veca 97];
VecC=[199 67];
Vecc=[231 99];
VecE=200:203;
VecE=[VecE 69];
Vece=232:1:235;
Vece=[Vece 101];
VecI=204:207;
VecI=[VecI 73];
Veci=236:1:239;
Veci=[Veci 105];
Vecn=[241 110];
VecO=210:214;
VecO=[VecO 216 79];
Veco=242:1:246;
Veco=[Veco 248 111];
VecU=217:1:220;
VecU=[VecU 85];
Vecu=249:1:252;
Vecu=[Vecu 117];
VecY=[221 89];
Vecy=[253 121];
Vecs=[223 115];
VecSpecialCharacters=[{VecA} {Veca} {VecC} {Vecc} {VecE} {Vece} {VecI} {Veci} {Vecn} {VecO} {Veco} {VecU} {Vecu} {VecY} {Vecy} {Vecs}];
ValueAffiliationEditor=ExtractAffiliation(VecEditors1Temp{n2,7},VecSpecialCharacters);
load([ValueFolderTemp 'ResultsThirdLevelDistributionOutliers.mat']);
VecDistribution=VecResults;
load([ValueFolderTemp2 'StartEditor' num2str(n2) '.mat']);
ValueCutoff=1.25;
if size(ValueMaxDate1,1)>1&&size(ValueMaxDate2,1)>1
    ValueFile=dir([ValueFolderTemp2 'ResultsCharacteristicsEditor' num2str(n2) '.mat']);
    if size(ValueFile,1)==1
        load([ValueFolderTemp2 'ResultsCharacteristicsEditor' num2str(n2) '.mat']);
        ValueDistributionTemp=find(VecDistribution(:,1)==n2);
        if size(ValueDistributionTemp,1)>0&&VecDistribution(ValueDistributionTemp,2)<=ValueCutoff
            VecValueYear=[0 1 2 3 4 5 10];
%             nMonthMax=7;
            nMonthMax=12;
            for n1=1:33
                eval(['VecResultsEditorAuthors1Journal' num2str(n1) '=zeros(2,2*nMonthMax*size(VecValueYear,2));']);
                eval(['VecResultsEditorAuthors2Journal' num2str(n1) '=zeros(2,2*nMonthMax*size(VecValueYear,2));']);
                eval(['VecResultsEditorAffiliation1Journal' num2str(n1) '=zeros(2,2*nMonthMax*size(VecValueYear,2));']);
                eval(['VecResultsEditorAffiliation2Journal' num2str(n1) '=zeros(2,2*nMonthMax*size(VecValueYear,2));']);
                eval(['VecResultsEditorAuthors1FilteredJournal' num2str(n1) '=zeros(2,2*nMonthMax*size(VecValueYear,2));']);
                eval(['VecResultsEditorAuthors2FilteredJournal' num2str(n1) '=zeros(2,2*nMonthMax*size(VecValueYear,2));']);
            end
            VecArticleType={'Academic Dissertation' 'Adaptive Clinical Trial' 'Clinical Trial' 'Comparative Study' 'Controlled Clinical Trial' 'Equivalence Trial' 'Evaluation Study' 'Journal Article' 'Meta-Analysis' 'Multicenter Study' 'Observational Study' 'Pragmatic Clinical Trial' 'Randomized Controlled Trial' 'Review' 'Statistics' 'Technical Report' 'Systematic Review' 'Twin Study' 'Validation Study'};
            VecArticleType2={'Review' 'Systematic Review'};
            ValueClock=clock;
            disp(['Start of the processing at ' num2str(ValueClock(1,4)) ':' num2str(ValueClock(1,5)) ':' num2str(ValueClock(1,6)) ' for journal ' num2str(n2)]);
            ValueFile=['FileAnalysisEditor' num2str(n2) '.mat'];
%             ValueFile=['FileAnalysisEditor' num2str(n2) 'Original.mat'];
            ValueFileTemp=dir([ValueFolderTemp2 ValueFile]);
            VecResults1=zeros(2,4);
            VecResultsBefore1=[];
            VecResultsAfter1=[];
            VecResultsBefore2=[];
            VecResultsAfter2=[];
            VecResultsAllBefore1=[];
            VecResultsAllAfter1=[];
            VecResultsAllBefore2=[];
            VecResultsAllAfter2=[];
            VecValueDateTemp={'Jan' 'Feb' 'Mar' 'Apr' 'May' 'Jun' 'Jul' 'Aug' 'Sep' 'Oct' 'Nov' 'Dec'};
            if size(ValueFileTemp,1)==0
                n1Temp2=0;
                try
                    ValueFile=['FileAnalysisEditorTemp' num2str(n2) '.mat'];
%                     ValueFile=['FileAnalysisEditorTemp' num2str(n2) 'Original.mat'];
                    load([ValueFolderTemp2 ValueFile]);
                    n1Temp2=n1;
                end
                n1Temp2=n1Temp2+1;
                for n1=n1Temp2:1062
                    n1
                    eval(sprintf('load([ValueFolder ''ResultsFile%d.mat'']);',n1));
                    for n5=1:33
                        % Loop over the articles of each Nature journal separately
                        eval(sprintf('VecValueTemp=VecResult2Journal%d;',n5));
                        VecResultsEditorAuthors1=zeros(2,2*nMonthMax*size(VecValueYear,2)); % First line=number of articles published by a co author of the editor before his arrival (first column) and after his arrival (second column) repeated 6 times (one for each month of shift of the arrivla date) for each duration considered in VecValueYear, second line=same as first one except that the authors are not co authors of the editor
                        VecResultsEditorAffiliation1=zeros(2,2*nMonthMax*size(VecValueYear,2)); % Same thing as VecResultsAditorAuthors except that it applies to the affiliation instead of the name of the author
                        VecResultsEditorAuthors2=zeros(2,2*nMonthMax*size(VecValueYear,2)); % First line=number of articles published by a co author of the editor before his arrival (first column) and after his arrival (second column), second line=same as first one except that the authors are not co authors of the editor
                        VecResultsEditorAffiliation2=zeros(2,2*nMonthMax*size(VecValueYear,2)); % Same thing as VecResultsAditorAuthors except that it applies to the affiliation instead of the name of the author
                        VecResultsEditorAuthors1Filtered=zeros(2,2*nMonthMax*size(VecValueYear,2)); % First line=number of articles published by a co author of the editor before his arrival (first column) and after his arrival (second column) repeated 6 times (one for each month of shift of the arrivla date) for each duration considered in VecValueYear, second line=same as first one except that the authors are not co authors of the editor
                        VecResultsEditorAuthors2Filtered=zeros(2,2*nMonthMax*size(VecValueYear,2)); % First line=number of articles published by a co author of the editor before his arrival (first column) and after his arrival (second column), second line=same as first one except that the authors are not co authors of the editor
                        for n3=1:size(VecValueTemp,1)
                            ValueTemp=VecValueTemp{n3,1};
                            if size(ValueTemp,2)>1
                                [ValueFirst,ValueLast,ValueAffiliation,ValueORCID,nAuthors]=ExtractAuthor(ValueTemp,0,1);
                                ValueArticleType=ComputeArticleType(VecValueTemp{n3,9},VecArticleType,VecValueTemp{n3,10},VecValueTemp{n3,11});
                                if ValueArticleType>0
                                    if nAuthors>1
                                        ValueArticleType3=1;
                                    else
                                        ValueArticleType3=2;
                                    end
                                else
                                    ValueArticleType3=0;
                                end
                                ValueDate=VecValueTemp{n3,5};
                                [ValueYear,ValueMonth,ValueDay]=ExtractDate(ValueDate);
                                if size(ValueYear,2)>0
                                    if size(ValueMonth,2)>=1
                                        ValueMonthTemp=str2num(ValueMonth);
                                        if size(ValueMonthTemp,2)==0
                                            n61=1;
                                            TestTemp3=0;
                                            while n61<=12&&TestTemp3==0
                                                if strcmpi(ValueMonth,VecValueDateTemp{1,n61})==1
                                                    ValueMonthTemp=n61;
                                                    TestTemp3=1;
                                                end
                                                n61=n61+1;
                                            end
                                        end
                                    else
                                        ValueMonthTemp=NaN;
                                    end
                                    ValueDateArticleTemp=[str2num(ValueYear) ValueMonthTemp NaN];
                                    VecResultsMaxDate1=[];
                                    VecResultsMaxDate2=[];
                                    for n64=1:size(VecValueYear,2)
                                        for n63=1:nMonthMax
                                            ValueMaxDate1Temp=ModifyDateEditor(ValueMaxDate1,n63-1,VecValueYear(1,n64));
                                            ValueMaxDate2Temp=ModifyDateEditor(ValueMaxDate2,n63-1,VecValueYear(1,n64));
                                            [ValueResults1,ValueResults2]=checkDateEditor(ValueDateArticleTemp,ValueMaxDate1Temp,ValueMaxDate2Temp);
                                            VecResultsMaxDate1=[VecResultsMaxDate1;ValueResults1 n63*ones(2,1) n64*ones(2,1)];
                                            VecResultsMaxDate2=[VecResultsMaxDate2;ValueResults2 n63*ones(2,1) n64*ones(2,1)];
                                        end
                                    end
                                    if sum(VecResultsMaxDate1(:,1))+sum(VecResultsMaxDate2(:,1))>=1
%                                     if sum(VecResultsMaxDate1(:,1))+sum(VecResultsMaxDate2(:,1))>=1&&ValueArticleType3==1
                                        % The article is within the date range of the editor
                                        TestTemp=0;
                                        VecResultsArticle=[];
                                        VecResultsAllArticle=[];
                                        ValueAffiliationTemp='';
                                        nAffiliation=0;
                                        ValueEditorTemp6=0;
                                        ValueAuthors61=0; % Co authors of the editor
                                        ValueAuthors62=0; % Others Authors
                                        ValueAuthorsFiltered61=0; % Co authors of the editor
                                        ValueAuthorsFiltered62=0; % Others Authors
                                        ValueAffiliation61=0; % Affiliation of the editor
                                        ValueAffiliation62=0; % Other affiliations
                                        for n4=1:nAuthors
                                            % Extraction of each author of the article
                                            [ValueFirst,ValueLast,ValueAffiliation,ValueORCID,nAuthors2]=ExtractAuthor(ValueTemp,n4,2);
                                            if strcmps(double([ValueLast ' ' ValueFirst]),double([LastNameEditor ' ' FirstNameEditor]),VecSpecialCharacters)<0.5
                                                ValueEditorTemp5=1;
                                            else
                                                ValueEditorTemp5=0;
                                                ValueEditorTemp6=1;
                                            end
                                            % Check if the affiliation related to the author is one of the ones of the editor
                                            if size(ValueAffiliation,2)>0
                                                nAffiliation=nAffiliation+1;
                                                if size(ValueAffiliationTemp,2)==0
                                                    ValueAffiliationTemp=ValueAffiliation;
                                                end
                                                ValueResult=checkAffiliationEditor(ValueAffiliation,ValueAffiliationEditor);
                                                ValueResultTemp=ValueResult;
                                                % Update outputs
                                                if ValueResult>0&&ValueEditorTemp5==1
                                                    ValueAffiliation61=1;
                                                else
                                                    if ValueEditorTemp5==1
                                                        ValueAffiliation62=1;
                                                    end
                                                end
                                            end
                                            % check if the author is a co author of the editor
                                            ValueResult=checkAuthorsEditorsNature([ValueLast ' ' ValueFirst],VecGroupCoAuthors,VecSpecialCharacters,0);
                                            ValueResultFiltered=checkAuthorsEditorsNature([ValueLast ' ' ValueFirst],VecGroupCoAuthors,VecSpecialCharacters,1);
                                            % Update outputs
                                            if ValueResult==1&&ValueEditorTemp5==1
                                                ValueAuthors61=1;
                                            else
                                                if ValueEditorTemp5==1
                                                    ValueAuthors62=1;
                                                end
                                            end
                                            % Update outputs for the case  in which co authors of the editor are restricted ot the first group
                                            if ValueResultFiltered==1&&ValueEditorTemp5==1
                                                ValueAuthorsFiltered61=1;
                                            else
                                                if ValueEditorTemp5==1
                                                    ValueAuthorsFiltered62=1;
                                                end
                                            end
                                        end
                                        % Update outputs for the affiliation
                                        if ValueAffiliation61==1
                                            for n65=1:size(VecResultsMaxDate1,1)/2
                                                ValueResults1=VecResultsMaxDate1((n65-1)*2+1:(n65-1)*2+2,1);
                                                ValueResults2=VecResultsMaxDate2((n65-1)*2+1:(n65-1)*2+2,1);
                                                if ValueResults1(1,1)==1
                                                    VecResultsEditorAffiliation1(1,(n65-1)*2+1)=VecResultsEditorAffiliation1(1,(n65-1)*2+1)+1;
                                                else
                                                    if ValueResults1(2,1)==1
                                                        VecResultsEditorAffiliation1(1,(n65-1)*2+2)=VecResultsEditorAffiliation1(1,(n65-1)*2+2)+1;
                                                    end
                                                end
                                                if ValueResults2(1,1)==1
                                                    VecResultsEditorAffiliation2(1,(n65-1)*2+1)=VecResultsEditorAffiliation2(1,(n65-1)*2+1)+1;
                                                else
                                                    if ValueResults1(2,1)==1
                                                        VecResultsEditorAffiliation2(1,(n65-1)*2+2)=VecResultsEditorAffiliation2(1,(n65-1)*2+2)+1;
                                                    end
                                                end
                                            end
                                        end
                                        if ValueAffiliation62==1
                                            for n65=1:size(VecResultsMaxDate1,1)/2
                                                ValueResults1=VecResultsMaxDate1((n65-1)*2+1:(n65-1)*2+2,1);
                                                ValueResults2=VecResultsMaxDate2((n65-1)*2+1:(n65-1)*2+2,1);
                                                if ValueResults1(1,1)==1
                                                    VecResultsEditorAffiliation1(2,(n65-1)*2+1)=VecResultsEditorAffiliation1(2,(n65-1)*2+1)+1;
                                                else
                                                    if ValueResults1(2,1)==1
                                                        VecResultsEditorAffiliation1(2,(n65-1)*2+2)=VecResultsEditorAffiliation1(2,(n65-1)*2+2)+1;
                                                    end
                                                end
                                                if ValueResults2(1,1)==1
                                                    VecResultsEditorAffiliation2(2,(n65-1)*2+1)=VecResultsEditorAffiliation2(2,(n65-1)*2+1)+1;
                                                else
                                                    if ValueResults1(2,1)==1
                                                        VecResultsEditorAffiliation2(2,(n65-1)*2+2)=VecResultsEditorAffiliation2(2,(n65-1)*2+2)+1;
                                                    end
                                                end
                                            end
                                        end
                                        % Update outputs
                                        if ValueAuthors61==1
                                            for n65=1:size(VecResultsMaxDate1,1)/2
                                                ValueResults1=VecResultsMaxDate1((n65-1)*2+1:(n65-1)*2+2,1);
                                                ValueResults2=VecResultsMaxDate2((n65-1)*2+1:(n65-1)*2+2,1);
                                                if ValueResults1(1,1)==1
                                                    VecResultsEditorAuthors1(1,(n65-1)*2+1)=VecResultsEditorAuthors1(1,(n65-1)*2+1)+1;
                                                else
                                                    if ValueResults1(2,1)==1
                                                        VecResultsEditorAuthors1(1,(n65-1)*2+2)=VecResultsEditorAuthors1(1,(n65-1)*2+2)+1;
                                                    end
                                                end
                                                if ValueResults2(1,1)==1
                                                    VecResultsEditorAuthors2(1,(n65-1)*2+1)=VecResultsEditorAuthors2(1,(n65-1)*2+1)+1;
                                                else
                                                    if ValueResults1(2,1)==1
                                                        VecResultsEditorAuthors2(1,(n65-1)*2+2)=VecResultsEditorAuthors2(1,(n65-1)*2+2)+1;
                                                    end
                                                end
                                            end
                                        end
                                        if ValueAuthors62==1
                                            for n65=1:size(VecResultsMaxDate1,1)/2
                                                ValueResults1=VecResultsMaxDate1((n65-1)*2+1:(n65-1)*2+2,1);
                                                ValueResults2=VecResultsMaxDate2((n65-1)*2+1:(n65-1)*2+2,1);
                                                if ValueResults1(1,1)==1
                                                    VecResultsEditorAuthors1(2,(n65-1)*2+1)=VecResultsEditorAuthors1(2,(n65-1)*2+1)+1;
                                                else
                                                    if ValueResults1(2,1)==1
                                                        VecResultsEditorAuthors1(2,(n65-1)*2+2)=VecResultsEditorAuthors1(2,(n65-1)*2+2)+1;
                                                    end
                                                end
                                                if ValueResults2(1,1)==1
                                                    VecResultsEditorAuthors2(2,(n65-1)*2+1)=VecResultsEditorAuthors2(2,(n65-1)*2+1)+1;
                                                else
                                                    if ValueResults1(2,1)==1
                                                        VecResultsEditorAuthors2(2,(n65-1)*2+2)=VecResultsEditorAuthors2(2,(n65-1)*2+2)+1;
                                                    end
                                                end
                                            end
                                        end
                                        % Update outputs for the case  in which co authors of the editor are restricted ot the first group
                                        if ValueAuthorsFiltered61==1
                                            for n65=1:size(VecResultsMaxDate1,1)/2
                                                ValueResults1=VecResultsMaxDate1((n65-1)*2+1:(n65-1)*2+2,1);
                                                ValueResults2=VecResultsMaxDate2((n65-1)*2+1:(n65-1)*2+2,1);
                                                if ValueResults1(1,1)==1
                                                    VecResultsEditorAuthors1Filtered(1,(n65-1)*2+1)=VecResultsEditorAuthors1Filtered(1,(n65-1)*2+1)+1;
                                                else
                                                    if ValueResults1(2,1)==1
                                                        VecResultsEditorAuthors1Filtered(1,(n65-1)*2+2)=VecResultsEditorAuthors1Filtered(1,(n65-1)*2+2)+1;
                                                    end
                                                end
                                                if ValueResults2(1,1)==1
                                                    VecResultsEditorAuthors2Filtered(1,(n65-1)*2+1)=VecResultsEditorAuthors2Filtered(1,(n65-1)*2+1)+1;
                                                else
                                                    if ValueResults1(2,1)==1
                                                        VecResultsEditorAuthors2Filtered(1,(n65-1)*2+2)=VecResultsEditorAuthors2Filtered(1,(n65-1)*2+2)+1;
                                                    end
                                                end
                                            end
                                        end
                                        if ValueAuthorsFiltered62==1
                                            for n65=1:size(VecResultsMaxDate1,1)/2
                                                ValueResults1=VecResultsMaxDate1((n65-1)*2+1:(n65-1)*2+2,1);
                                                ValueResults2=VecResultsMaxDate2((n65-1)*2+1:(n65-1)*2+2,1);
                                                if ValueResults1(1,1)==1
                                                    VecResultsEditorAuthors1Filtered(2,(n65-1)*2+1)=VecResultsEditorAuthors1Filtered(2,(n65-1)*2+1)+1;
                                                else
                                                    if ValueResults1(2,1)==1
                                                        VecResultsEditorAuthors1Filtered(2,(n65-1)*2+2)=VecResultsEditorAuthors1Filtered(2,(n65-1)*2+2)+1;
                                                    end
                                                end
                                                if ValueResults2(1,1)==1
                                                    VecResultsEditorAuthors2Filtered(2,(n65-1)*2+1)=VecResultsEditorAuthors2Filtered(2,(n65-1)*2+1)+1;
                                                else
                                                    if ValueResults1(2,1)==1
                                                        VecResultsEditorAuthors2Filtered(2,(n65-1)*2+2)=VecResultsEditorAuthors2Filtered(2,(n65-1)*2+2)+1;
                                                    end
                                                end
                                            end
                                        end
                                    end
                                end
                            end
                        end
                        eval(['VecResultsEditorAuthors1Journal' num2str(n5) '=VecResultsEditorAuthors1Journal' num2str(n5) '+VecResultsEditorAuthors1;']);
                        eval(['VecResultsEditorAuthors2Journal' num2str(n5) '=VecResultsEditorAuthors2Journal' num2str(n5) '+VecResultsEditorAuthors2;']);
                        eval(['VecResultsEditorAffiliation1Journal' num2str(n5) '=VecResultsEditorAffiliation1Journal' num2str(n5) '+VecResultsEditorAffiliation1;']);
                        eval(['VecResultsEditorAffiliation2Journal' num2str(n5) '=VecResultsEditorAffiliation2Journal' num2str(n5) '+VecResultsEditorAffiliation2;']);
                        eval(['VecResultsEditorAuthors1FilteredJournal' num2str(n5) '=VecResultsEditorAuthors1FilteredJournal' num2str(n5) '+VecResultsEditorAuthors1Filtered;']);
                        eval(['VecResultsEditorAuthors2FilteredJournal' num2str(n5) '=VecResultsEditorAuthors2FilteredJournal' num2str(n5) '+VecResultsEditorAuthors2Filtered;']);
                    end
%                     if mod(n1,3)==0
%                         ValueFile=['FileAnalysisEditorTemp' num2str(n2) '.mat'];
% %                         ValueFile=['FileAnalysisEditorTemp' num2str(n2) 'Original.mat'];
%                         save([ValueFolderTemp2 ValueFile]);
%                     end
                end
                ValueFile=['FileAnalysisEditor' num2str(n2) '.mat'];
    %             ValueFile=['FileAnalysisEditor' num2str(n2) 'Original.mat'];
                VecResults1=1;
                ValueTemp='save([ValueFolderTemp2 ValueFile]';
                for n65=1:33
                    ValueTemp=[ValueTemp ',''VecResultsEditorAuthors1Journal' num2str(n65) ''',''VecResultsEditorAuthors2Journal' num2str(n65) ''',''VecResultsEditorAffiliation1Journal' num2str(n65) ''',''VecResultsEditorAffiliation2Journal' num2str(n65) ''',''VecResultsEditorAuthors1FilteredJournal' num2str(n65) ''',''VecResultsEditorAuthors2FilteredJournal' num2str(n65) ''''];
                end
                ValueTemp=[ValueTemp ',''ValueMaxDate1'',''ValueMaxDate2'',''VecGroupCoAuthors'',''VecResults1'');'];
                eval(ValueTemp);
            end
            ValueClock=clock;
            disp(['End of the processing at ' num2str(ValueClock(1,4)) ':' num2str(ValueClock(1,5)) ':' num2str(ValueClock(1,6)) ' for journal ' num2str(n2)]);
        else
            VecResults1=0;
            ValueFile=['FileAnalysisEditor' num2str(n2) '.mat'];
%             ValueFile=['FileAnalysisEditor' num2str(n2) 'Original.mat'];
            save([ValueFolderTemp2 ValueFile],'VecResults1');
        end
    end
else
    VecResults1=0;
    ValueFile=['FileAnalysisEditor' num2str(n2) '.mat'];
%     ValueFile=['FileAnalysisEditor' num2str(n2) 'Original.mat'];
    save([ValueFolderTemp2 ValueFile],'VecResults1');
end
    
    